﻿<vsx.ui:DialogWindow x:Class="Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views.CodeAnalysisProgressWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:vsx.ui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.10.0"
                     xmlns:local.views="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views"
                     xmlns:local.converter="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views.Converters"
                     xmlns:local.viewmodels="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.ViewModels"
                     x:Name="this"
                     Title="Code Analysis Progress"
                     HasMinimizeButton="False"
                     HasMaximizeButton="False"
                     WindowStartupLocation="CenterOwner"
                     MinHeight="400" Height="400" MinWidth="800" Width="800">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <TextBlock Margin="5">
                <TextBlock.Text>
                    <Binding Path="FxCopVersion" StringFormat="FxCopCmd.exe Version : {0}">
                        <Binding.Converter>
                            <local.converter:FxCopVersionConverter/>
                        </Binding.Converter>
                    </Binding>
                </TextBlock.Text>
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding FxCopVersion}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
            <TextBlock Margin="5">
                <TextBlock.Text>
                    <Binding Path="MetricsVersion" StringFormat="Metrics.exe Version : {0}">
                        <Binding.Converter>
                            <local.converter:MetricsVersionConverter/>
                        </Binding.Converter>
                    </Binding>
                </TextBlock.Text>
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding MetricsVersion}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </StackPanel>
        <ListView Grid.Row="1" ItemsSource="{Binding CodeAnalyzers}" Margin="0,0,0,5">
            <ListView.View>
                <GridView>
                    <GridViewColumn>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image Width="16" Height="16" Margin="2">
                                    <Image.Style>
                                        <Style TargetType="Image">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Pending}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisPending.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Analyzing}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisRunning.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Completed}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisCompleted.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Failed}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisFailed.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Warning}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisWarning.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.Skip}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisSkipped.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static local.viewmodels:CodeAnalysisStatus.CompletedOnBuildTime}">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/CodeAnalysisCompleted.png"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Target" DisplayMemberBinding="{Binding Target}" Width="300"/>
                    <GridViewColumn Header="Message" Width="400">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
                                    <ItemsControl ItemsSource="{Binding Warnings}"/>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid Grid.Row="2">
            <Button IsCancel="True" Width="60" HorizontalAlignment="Right">
                <Button.Style>
                    <Style TargetType="Button">
                        <Setter Property="Command" Value="{Binding CloseCommand}"/>
                        <Setter Property="Content" Value="Close"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Status}" Value="Analyzing">
                                <Setter Property="Command" Value="{Binding CancelCommand}"/>
                                <Setter Property="Content" Value="Cancel"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </Grid>
    </Grid>
</vsx.ui:DialogWindow>
